#ifndef __SYS_DEF_H__
#define __SYS_DEF_H__

#include "stdint.h"

#ifdef __cplusplus
extern "C" {
#endif

#define PB_USART0                   1
//#define EN_I2C                    1
//#define EN_SPI0                   1

#define DEBUG_UART		            USART0
#define UPGRADE_UART	            USART1
#define COM_UART                    USART1

/*The following definition is for GD32F350CB*/
#define USE_FMC_FLASH               1
//#define USE_SPI_FLASH             1
#define FMC_START_ADDR              NVIC_VECTTAB_FLASH                              /* Flash Start Address */
#define FMC_PAGE_SIZE               (1024)
#define FMC_PAGE_COUNT              (128)
#define BOOTLOADER_PAGE_COUNT       (32)
#define FACTORY_APP_PAGE_COUNT      (40)
#define USER_DATA_PAGE_COUT         (1)
#define USER_APP_PAGE_COUNT         (FMC_PAGE_COUNT - BOOTLOADER_PAGE_COUNT - FACTORY_APP_PAGE_COUNT - USER_DATA_PAGE_COUT)
#define BOOTLOADER_SIZE             (BOOTLOADER_PAGE_COUNT * FMC_PAGE_SIZE)
#define FACTORY_APP_SIZE            (FACTORY_APP_PAGE_COUNT * FMC_PAGE_SIZE)
#define USER_APP_ADDR               ((uint32_t)(FMC_START_ADDR + BOOTLOADER_SIZE + FACTORY_APP_SIZE))
#define USER_APP_SIZE               (USER_APP_PAGE_COUNT * FMC_PAGE_SIZE)
#define USER_DATA_ADDR              ((uint32_t)(FMC_START_ADDR + ((FMC_PAGE_COUNT - USER_DATA_PAGE_COUT) * FMC_PAGE_SIZE)))
#define USER_DATA_SIZE              (USER_DATA_PAGE_COUT * FMC_PAGE_SIZE)
#define ONLINE_UART_UPGRADE_FLAG    0xA0A0A0A0
#define ONLINE_VCOM_UPGRADE_FLAG    0xB0B0B0B0

#ifdef __cplusplus
}
#endif

#endif
